package com.example.shoppingmall.service;

import com.example.shoppingmall.pojo.Commodity;
import com.example.shoppingmall.dao.CommodityMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommodityService {
    @Autowired
    private CommodityMapper commodityMapper;

    public int countAll(){
        return commodityMapper.countAll();
    }

    public int countUp(){
        return commodityMapper.countUp();
    }

    public int countDown(){
        return commodityMapper.countDown();
    }

    public int countRepertory(){
        return commodityMapper.countRepertory();
    }

    public List<Commodity> commodityList(@Param("name")String name, @Param("status")int status, @Param("repertory")int repertory,
                                           @Param("no")int no){
        return commodityMapper.commodityList(name,status,repertory,no);
    }

    public int countList(@Param("name")String name,@Param("status")int status,@Param("repertory")int repertory){
        return commodityMapper.countList(name,status,repertory);
    }

    public int delete(@Param("id")int id){
        return commodityMapper.delete(id);
    }

    public int add(Commodity commodity){
        return commodityMapper.add(commodity);
    }

    public int chackName(@Param("name")String name){
        return commodityMapper.chackName(name);
    }

    public Commodity xiangQing(@Param("id")int id){
        return commodityMapper.xiangQing(id);
    }

    public int update(Commodity commodity){
        return commodityMapper.update(commodity);
    }

    public int update1(Commodity commodity){
        return commodityMapper.update1(commodity);
    }

    public int updateUp(@Param("id")int id){
        return commodityMapper.updateUp(id);
    }

    public int updateDown(@Param("id")int id){
        return commodityMapper.updateDown(id);
    }

    public List<Commodity>list(){
        return commodityMapper.list();
    }

    public int addAll(@Param("commodities")List<Commodity>commodities){
        for (Commodity commodity : commodities) {
            System.out.println(commodity);
        }
        return commodityMapper.addAll(commodities);
    }
}
